package com.example.xm.servive.impl;

import com.example.xm.Entity.Dd;
import com.example.xm.config.PageResult;
import com.example.xm.mapper.DdMapper;
import com.example.xm.servive.DdServive;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DdServiveImpl implements DdServive {
    @Autowired
    DdMapper ddMapper;

    @Override
    public List<Dd> getAllDd(Dd dd) {
        return ddMapper.getAllDd(dd);
    }

    /**
     * 分页
     * */
    @Override
    public PageResult selectPager(int pageNum, int pageSize, Dd dd) {
        //开始分页，指定页码与每页记录数
        PageHelper.startPage(pageNum,pageSize);
        //执行查询，请求会被分页插件拦截
        List<Dd> students = ddMapper.getAllDd(dd);
        //返回分页对象与数据
        return PageResult.getPageResult(new PageInfo<Dd>(students));
    }

    /**添加到订单*/
    @Override
    public void addMultipleData(List<Dd> dataList) {
        ddMapper.addMultipleData(dataList);
    }

    @Override
    public int AddDdh(Dd dd) {
        return ddMapper.AddDdh(dd);
    }

    @Override
    public int UpdateDd(Dd dd) {
        return ddMapper.UpdateDd(dd);
    }
}
